PROJECT_DIR = $(shell pwd)
BIN_DIR = $(PROJECT_DIR)/bin
PATH := $(BIN_DIR):$(PATH)
CONFIG_PATH = $(PROJECT_DIR)/configs/test.toml
BINARY = fapi
GOLANGCI_LINT_VERSION = v1.57.1

GOLANGCI_LINT = $(BIN_DIR)/golangci-lint
ifeq ($(OS), Windown_NT)
	BINARY := $(BINARY).exe
	GOLANGCI_LINT := $(GOLANGCI_LINT).exe
endif

$(shell [ -f $(BIN_DIR) ] || mkdir -p $(BIN_DIR))


.PHONY:build
build:
	go build -o $(BIN_DIR)/$(BINARY) ./cmd/fapi



.PHONY:test
test:
	go test -v --timeout 30s ./...

.PHONY:.install-linter
.install-linter:
	$(shell [ -f $(GOLANGCI_LINT) ] || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(BIN_DIR) $(GOLANGCI_LINT_VERSION))

.PHONY:lint
lint:.install-linter
	$(GOLANGCI_LINT) run ./... --config=./.golangci.yml

.PHONY:lint-fast
lint-fast:.install-linter
	$(GOLANGCI_LINT) run ./... --fast --config=./.golangci.yml



.DEFAULT_GOAL := build